package com.braveman.im.factory;


import android.os.Bundle;
import android.util.SparseArray;

import com.braveman.im.ui.fragment.CircleFriendsFragment;
import com.braveman.im.ui.fragment.MessageFragment;
import com.braveman.im.ui.fragment.MineFragment;
import com.braveman.im.ui.fragment.ShoppingCircleFragment;
import com.ht.baselibs.ui.base.BaseFragment;
import com.braveman.im.ui.fragment.ResourceFragment;


public class FragmentFactory {

    public static final int FRAGMENT_HOME_TAB0 = 0;
    public static final int FRAGMENT_HOME_TAB1 = 1;
    public static final int FRAGMENT_HOME_TAB2 = 2;
    public static final int FRAGMENT_HOME_TAB3 = 3;
    public static final int FRAGMENT_HOME_TAB4 = 4;

    public static final SparseArray<BaseFragment> mHomeTabMap = new SparseArray();

    public static BaseFragment getHomeTabFragment(int position) {
        BaseFragment fragment = mHomeTabMap.get(position);

        if (fragment == null) {
            switch (position) {
                case FRAGMENT_HOME_TAB0:
                    fragment = new MessageFragment();
                    break;
                case FRAGMENT_HOME_TAB1:
                    fragment = new CircleFriendsFragment();
                    break;
                case FRAGMENT_HOME_TAB2:
                    fragment = new ResourceFragment();
                    break;
                case FRAGMENT_HOME_TAB3:
                    fragment = new ShoppingCircleFragment();
                    break;
                case FRAGMENT_HOME_TAB4:
                    fragment = new MineFragment();
                    break;

            }
            mHomeTabMap.put(position, fragment);
            Bundle bundle = new Bundle();
            bundle.putBoolean(BaseFragment.IS_ATTACH_FRAGMENT_LAYOUT, true);
            fragment.setArguments(bundle);
        }
        return fragment;
    }
}
